package com.czx.mygithubclient;

import android.os.Bundle;
import android.util.Log;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ProgressBar;

import com.jakewharton.rxbinding.widget.RxTextView;
import com.jakewharton.rxbinding.widget.TextViewTextChangeEvent;

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import rx.Subscription;
import rx.functions.Action1;

public class SplashActivity extends BaseActivity {

    @Inject
    SplashActivityPresenter mPresenter;
    @BindView(R.id.editText)
    EditText editText;
    @BindView(R.id.button)
    Button button;
    @BindView(R.id.progressBar)
    ProgressBar progressBar;


    private Subscription textChangeSubscription;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_splash);
        ButterKnife.bind(this);


        textChangeSubscription = RxTextView.textChangeEvents(editText).subscribe(new Action1<TextViewTextChangeEvent>() {
            @Override
            public void call(TextViewTextChangeEvent textViewTextChangeEvent) {
                mPresenter.username = textViewTextChangeEvent.text().toString();
                Log.i("test", mPresenter.username);
//                editText.setError(null);
            }
        });

        Log.i("test", mPresenter.toString());
    }

    @Override
    public void setUpComponent() {
        SplashActivityComponent splashActivityComponent = DaggerSplashActivityComponent
                .builder().splashActivityModule(new SplashActivityModule(this)).build();
        splashActivityComponent.inject(this);
    }


    @OnClick(R.id.button)
    public void onClick() {
    }
}
